import { getUrl, getResUrl } from '@/api/apibase.js'

export function getUploadingImgUrl(data) {
  // return getUrl('Uploading/image')
  return getResUrl('manage/Uploading/image')
}


export function getUploadingVideoUrl() {
  // return getUrl('Uploading/video')
  return getResUrl('manage/Uploading/video')
}

export function getImgUrl(url) {
  // return url
  return getResUrl(url)
}

export function getResourceUrl(url) {
  return getResUrl(url)
}


export function imgstrTransitionArray(str_url) {
  var imgArray = stringToArray(str_url)
  var url = ''
  for (var j = 0; j < imgArray.length; j++) {
    url = imgArray[j]
    url =  url.replace(/\s+/g, ''); 
    console.log(url,'urlurlurlurlurlurlurl111')
    imgArray[j] = getImgUrl(url);
  }
  return imgArray
}



export function stringToArray(str, delimiter = ',') {
  // 检查传入的参数是否是字符串
  if (typeof str !== 'string') {
    return [];
  }

  if (str == "") {
    return [];
  }

  // 检查传入的分隔符是否是字符串
  if (typeof delimiter !== 'string') {
    console.error('The delimiter must be a string.');
    throw new Error('The delimiter must be a string.');
  }

  // 检查分隔符是否为空
  if (delimiter.length === 0) {
    console.error('The delimiter cannot be an empty string.');
    throw new Error('The delimiter cannot be an empty string.');
  }

  // 将字符串根据分隔符分割成数组
  return str.split(delimiter);
}
